package slxy.jiangtao.dts.core.common.bean;

import java.util.Arrays;
import java.util.Optional;

/**
 * Created by JiangTao on 15/10/21.
 */
public enum Platform {
    //无:0, Web:1, 安卓:2,iOS:3, WebApp:4
    None(0),
    Web(1),
    Android(2),
    iOS(3),
    WebApp(4);

    private Integer platformCode;

    Platform(Integer platformCode) {
        this.platformCode = platformCode;
    }

    @Override
    public String toString() {
        return String.valueOf(this.platformCode);
    }

    /**
     * 将字符串转化为枚举
     *
     * @param platCode
     * @return
     */
    public static Optional<Platform> toEnum(String platCode) {
        return Arrays.stream(Platform.values()).filter(platform -> platform.toString().equals(platCode)).findFirst();
    }

}
